package cn.thrjit.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.thrjit.pojo.domain.Driver;
import cn.thrjit.pojo.domain.DriverAuthMaterial;
import cn.thrjit.pojo.query.PageQueryWrapper;
import cn.thrjit.result.R;
import cn.thrjit.service.IDriverAggrementService;
import cn.thrjit.service.IDriverAuthMaterialService;
import cn.thrjit.service.IDriverService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;
import reactor.util.annotation.NonNull;

import java.util.List;

@Tag(name = "司机的注册",description = "司机的注册")
@RestController
@RequestMapping("/app/driver")
public class AppController {
    @Autowired
    private IDriverService driverService;
    @Autowired
    private IDriverAuthMaterialService driverAuthMaterialService;
    /**
     * 小程序司机注册
     *
     * @param openId 前端发送的code
     * @return
     */
    @GetMapping("/register/{openId}/{phoneCode}")
    @Operation( summary= "小程序司机注册",description = "小程序司机注册")
    @Parameter(name = "openId",description = "获取openId的code",required = true)
    @SaIgnore
    // 通过@NonNull进行参数非空判断
    public R<Void> getOpenId(@PathVariable("openId")String openId,@PathVariable("phoneCode")String phoneCode){
        driverService.register(openId,phoneCode);
        return R.success();
    }

    /**
     * 小程序司机实名认证信息提交
     * @param
     * @return
     */
    @Operation( summary= "保存司机认证信息",description = "保存司机认证信息接口")
    @Parameter(name = "driver",description = "保存的对象",required = true)
    @PostMapping(value = "/saveRealAuth")
    public R<DriverAuthMaterial> saveRealAuth(@RequestBody DriverAuthMaterial driverAuthMaterial){
        driverAuthMaterialService.saveRealAuth(driverAuthMaterial);
        return R.success();
    }

    /**
     * 查询司机认证信息
     * @param
     * @return
     */
    @Operation( summary= "查询司机认证信息",description = "查询司机认证信息接口")
    @Parameter(name = "司机认证信息",description = "保存的对象",required = true)
    @PostMapping(value = "/realAuthInfo")
    public R<Void> realAuthInfo(){
        return R.success(driverService.getRealAuthInfo());
    }
}
